package cn.harry.modular.sys.service.impl;

import cn.harry.common.utils.RedisKeys;
import cn.harry.common.utils.RedisUtils;
import cn.harry.modular.sys.service.SysCaptchaService;
import org.springframework.stereotype.Service;

/**
 * 图片验证码
 *
 * @author honghh Date 2019-10-12 10:55:44 Copyright (C) www.tech-harry.cn
 */
@Service
public class SysCaptchaServiceImpl implements SysCaptchaService {

	@Override
	public boolean validate(String uuid, String code) {
		// 从redis中获取验证码
		String redisCode = RedisUtils.get(RedisKeys.getCaptchaKey(uuid));
		if (redisCode == null) {
			return false;
		}
		return redisCode.equalsIgnoreCase(code);
	}

}